<h2>Editer Catégorie</h2>
<div id="ajax-response"></div>
<form name="edittag" id="edittag" method="post" action="<?php echo $CFG->config['base_url']?>category/admin" class="validate">
<table class="form-table">
		<tbody>
		<tr class="form-field form-required">
			<th scope="row" valign="top"><label for="name">Actif</label></th>
			<td><input name="active" id="active" value="<?php echo $category->active?>" size="40" aria-required="true" type="checkbox" <?php echo $category->active?'checked':''?>/>
			</td>
		</tr>
		<tr class="form-field form-required">
			<th scope="row" valign="top"><label for="name">Nom</label></th>
			<td><input id="tag-name" name="name" value="<?php echo $category->name?>" size="40" aria-required="true" type="text"/>
			<p class="description">Nom de la catégorie (Afficher sur le site)</p></td>
		</tr>
		<tr class="form-field">
			<th scope="row" valign="top"><label for="slug">URL</label></th>
			<td><input id="tag-slug" name="slug" value="<?php echo $category->slug?>" size="40" type="text"/>
			<p class="description">L'URL simplifié est généré automatiquement. Il doit être en minuscules, uniquement des Lettres/Chiffres et  traits d'union pour les espace.</p></td>
		</tr>
		<tr class="form-field">
			<th scope="row" valign="top"><label for="slug">Mots Clefs</label></th>
			<td><input id="keywords" name="keywords" value="<?php echo $category->keywords?>" size="40" type="text"/>
			<p class="description">Obligatoirement séparé par , (Virgule)</p></td>
		</tr>
		
		<tr class="form-field">
			<th scope="row" valign="top"><label for="description">Description</label></th>
			<td><textarea name="description" id="description" rows="5" cols="40"></textarea>
			<p class="description">Maxium 150 characterse ou soit mots</p></td>
		</tr>
		<tr class="form-field">
			<th scope="row" valign="top"><label for="parent">Parent</label></th>
			<td>
				<select name="parent" id="parent" class="postform">
					<option value="0">Aucun</option>
					<?php echo $option_category?>
				</select>
				<p class="description"><br />Les Catégories peuvent avoir une hiérachie. Exemple catégorie principale &quot;Voiture&quot; et sous catégorie &quot;Electrique&quot; et &quot;Essence&quot;							</td>
		</tr>
		<tr class="form-field">
			<th scope="row" valign="top"><label for=""Order"">Order option</label></th>
			<td>
				<input id="Order" name="order_option" type="hidden" value="<?php echo $category->option?>"/>
				<div class="order">
				
				<?php 
				$option=explode(',',$category->option);
				$CategoryOption= array_flip($option);
				if(!empty($CategoryListOption))
					foreach($CategoryListOption as $list)
						if(is_array($option) and in_array($list->id_type,$option))
							$CategoryOption[$list->id_type]= $list->name;
						
				if(!empty($CategoryOption)){
				foreach ($CategoryOption as $id=>$NameOption)
					echo "
					<div id='$id'><i class='icon-arrow-up btn-link'></i> <i class='icon-arrow-down btn-link'></i> $NameOption</div>					
					";

				}	
				?>
				</div>
			</div>
			
<script type="text/javascript">
	function order(){
		var order='';
		$( ".order div" ).each(function( index ) {
			order+=$(this).attr('id')+',';
		});
		$('#Order').val(order);
	}
    $(document).ready(function() {
        $('.icon-arrow-up').click(function() {
            var parent = $(this).parent();
            parent.insertBefore(parent.prev());
            order()
        });
        $('.icon-arrow-down').click(function() {
            var parent = $(this).parent();
            parent.insertAfter(parent.next());
            order();
        });
    });
</script>
			</td>
		</tr>
		<tr class="form-field">
			<th scope="row" valign="top"><label for="showPrice">Afficher le prix ?</label></th>
			<td>
				<input id="showPrice" name="showPrice" value="<?php echo $category->showPrice?>" type="checkbox" <?php echo $category->showPrice?'checked="checked"':''?>/>
			</td>
		</tr>
		<tr class="form-field">
			<th height="128" valign="top" scope="row"><label for="description">Option</label></th>
			<td>
			<fieldset>
			<legend class="screen-reader-text">
			<span>Option</span>
			</legend>
<?php
	$option=explode(',',$category->option);
	if(!empty($CategoryListOption))
		foreach($CategoryListOption as $list){
			$s='';
			if(is_array($option) and in_array($list->id_type,$option))
				$s=' checked="checked" ';
	?>
	<label title="<?php echo $list->name?>" for="opt<?php echo $list->id_type?>">
		<input id="opt<?php echo $list->id_type?>" type="checkbox" value="<?php echo $list->id_type?>" name="option[]" <?php echo $s?>/>
		<span><?php echo $list->name?></span>
	</label>
	<br/>
	<?php }?>
	</fieldset>


			<p>
			Les options correspondent aux filtres misent en place pour chaque catégorie.<br />
			Ils doivent etre selectionner lors de la création de la catégorie.<br />
			Exemple : Catégorie 'Voiture' qui possede une option (Filtre) 'Essence' et 'Diésel'<br />
			Celle ci peuvent etre modifier a tout moment dans le BackOffice uniquement.
			</p>
			</td>
		</tr>
			</tbody>
</table>
<p class="submit">
	<input name="Update_Category" id="submit" class="button button-primary" value="Mise à jour" type="submit"/>
	<input name="id" id="id" value="<?php echo $category->id?>" type="hidden"/>
</p>
</form>
</div>
<script type="text/javascript">
try{document.forms.edittag.name.focus();}catch(e){}
</script>

<div class="clear"></div>